<template>
  <div class="wraper">
    <swiper :options="swiperOption" ref="mySwiper" v-if="showSwiper">
      <swiper-slide v-for="item in list" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl" />
      </swiper-slide>
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'carrousel',
  props: {
    list: Array
  },
  data () {
    return {
      imgList: [
        {
          id: '0001',
          imgUrl: 'https://imgs.qunarzz.com/vc/67/f1/0c/5e45d895a08df85d2bf7af3d31.jpg_90.jpg'
        },
        {
          id: '0002',
          imgUrl: 'https://imgs.qunarzz.com/vc/c8/26/54/c1d8c4c9fd791daf73c37a2fc5.jpg_90.jpg'
        }
      ],
      swiperOption: {
        autoplay: 3000,
        loop: true,
        pagination: '.swiper-pagination'
      }
    }
  },
  computed: {
    swiper () {
      return this.$refs.mySwiper.swiper
    },
    showSwiper () {
      return this.list.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  .wraper >>> .swiper-pagination-bullet-active
    background: #fff !important
  .wraper
    width: 100%
    height: 0
    overflow: hidden
    padding-bottom: 25.2%
    .swiper-img
      width: 100%
</style>
